Skip to content

feat(node): pooled resource scope#377

Merged
pratyush618 merged 3 commits into
masterfrom
feat/node-resource-pool
Jul 6, 2026
Merged

feat(node): pooled resource scope#377
pratyush618 merged 3 commits into
masterfrom
feat/node-resource-pool

Conversation

@pratyush618

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a "pooled" resource scope — a bounded checkout/return pool per resource, implementing the cross-SDK pooled-resource contract.
  • New ResourcePool with a private promise-based FIFO semaphore (per-waiter unref'd timeout, waiter removed on timeout so a later permit goes to a live caller). Checkout waits up to acquireTimeoutMs (default 10s) then throws the new ResourceUnavailableError; idle instances are reused until maxLifetimeMs evicts them; active moves only after the factory resolves and the permit is returned on factory rejection, so capacity never leaks. Prewarm tops the idle list up to poolMin (idempotent across worker leases) and is best-effort.
  • Registration: queue.resource(name, factory, { scope: "pooled", pool: { poolSize, poolMin, acquireTimeoutMs, maxLifetimeMs } }); pool options without the pooled scope are rejected.
  • Runtime: one checkout per task per resource (pending checkout cached before awaiting, so concurrent resolves share it); task teardown releases back to the pool — never disposes; worker teardown shuts pools down before worker resources; created/disposed metrics move only on actual build/eviction/shutdown.
  • Guard: a pooled factory may only use worker-scoped dependencies — pooled instances outlive tasks (ResourceScopeError message now names both scopes).
  • Docs: pooled scope added to the resources guide and dependency-injection page.

Test plan

  • 15 new tests: 6 ResourcePool unit (reuse, timeout, capacity safety, prewarm, lifetime eviction, stats), 5 runtime-level, 4 worker-integration.
  • pnpm typecheck, pnpm lint, full suite 263 tests green; docs types:check + lint green.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 13 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 958c7968-c9db-4dd2-96de-cdd293348cdd

📥 Commits

Reviewing files that changed from the base of the PR and between bf31a5a and ef95df5.

📒 Files selected for processing (10)
  • docs/content/docs/node/guides/resources/dependency-injection.mdx
  • docs/content/docs/node/guides/resources/index.mdx
  • sdks/node/src/errors.ts
  • sdks/node/src/index.ts
  • sdks/node/src/queue.ts
  • sdks/node/src/resources/index.ts
  • sdks/node/src/resources/pool.ts
  • sdks/node/src/resources/runtime.ts
  • sdks/node/src/resources/types.ts
  • sdks/node/test/resources/resources.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/node-resource-pool

Comment @coderabbitai help to get the list of available commands.

@pratyush618
pratyush618 merged commit a53e37e into master Jul 6, 2026
19 checks passed
@pratyush618
pratyush618 deleted the feat/node-resource-pool branch July 6, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant